;--------------------------------------
;
; movefp.asm
; 
; write file via DOS
;

;--------------------------------------
;
; include defs, prototypes and macros
;

include tab6.inc

;--------------------------------------
;
; begin code segment
;

	.CODE

moveFilePtr PROC PASCAL USES ds dx di bx cx,hdl:WORD,m:BYTE,offs:PWORD,noff:PWORD

; write file DOS function to ah

        mov     ah,42h

; place m code in al

        mov     al,m

; place file hdl in bx

        mov     bx,hdl

; dx:cx holds file offset distance

        IF mdl eq 3
        lds     si,offs
        ELSE
        mov     si,offs
        ENDIF

        mov     dx,Word Ptr ds:[si]
        add     si,2
        mov     cx,Word Ptr ds:[si]
        
; write file via int 21h

        int     21h

; carry set on error / branch on error

        jc      dos_error

; no error and ax returns 0
; return new file pointer location
; via noff pointer

        IF mdl eq 3
        lds     si,noff
        ELSE
        mov     si,noff
        ENDIF

        mov     Word Ptr ds:[si],dx ; msw new file ptr loc
        add     si,2                ; adjust pointer
        mov     Word Ptr ds:[si],ax ; lsw new file ptr loc


        sub     ax,ax
        ret

; error code via ax

dos_error:

        ret

moveFilePtr ENDP

        END

;
; end of movefp.asm
;--------------------------------------



